package com.jsn.hello_cmake

class algo {

    companion object{

    }

    fun traversal(tree:Node){
        if(tree.sonNodeList.size==0)
        {
            println(tree.value)
            return
        }
        tree.sonNodeList.map {
            traversal(it)
        }

    }


    open class Node(sonNode: AbstractMutableList<Node> , value:Int){

        var sonNodeList=sonNode

        var value=value
        init {

        }
    }

    fun postorderTraversal(root: algor.TreeNode?): List<Int> {

        val result= mutableListOf<Int>()
        _postorderTraversal(root,result as ArrayList<Int>)
        return  result
    }


    fun _postorderTraversal(root: algor.TreeNode?, result: ArrayList<Int> ) {

        root?.apply {
            root.left?.apply {
                _postorderTraversal(root.left,result)
            }
            root.right?.apply {
                _postorderTraversal(root.right,result)
            }
            result.add(root.`val`)
        }

    }




    open class TreeNode(var value: Int) {
             var left: TreeNode? = null
             var right: TreeNode? = null
         }

    fun recoverTree(root: TreeNode?): Unit {
        root?.apply {
        }
    }




}